{% extends "BlackhouseappBluehouseappBundle:layout:layout.html.twig" %}

{% block title %}蓝房子{% endblock %}
{% block body %}

    <div class="h20"></div>
    <div class="box">
        <div class="box-inner" id="tabs" style="background-color: #fff; border-top-left-radius: 3px; border-top-right-radius: 3px;">
            {% for category in categories %}
                {% if category.getId()==currentCategory.getId() %}
                    <a href="{{ path('post_by_category', { 'currentCategoryId': category.id }) }}" class="tab_current">{{ category.name }}</a>

                {% else %}
                    <a href="{{ path('post_by_category', { 'currentCategoryId': category.id }) }}" class="tab">{{ category.name }}</a>
                {% endif%}
            {% endfor %}

        </div>
        <div class="box-cell" style="background-color: #f9f9f9;">
            {% if currentCategory%}
                {% set nodes=currentCategory.nodes %}
                {% for node in nodes %}
                    <a href="{{ path('post_by_node', { 'currentNodeId': node.id }) }}" class="node">{{ node.name }}</a>
                {% endfor %}
                {% if currentNode%}
                    <div class="fr">
                        <a href="{{ path('post_new', { 'nodeId': currentNode.id }) }}" class="node">创建新主题</a>
                    </div>
                {% endif%}
            {% endif%}
        </div>


        {% for entity in entities %}
            <div class="box-cell box-item" style="border-top-left-radius: 3px; border-top-right-radius: 3px;">
                <div style="position: absolute; margin: -10px -10px 0px 650px;"></div>
                <table cellpadding="0" cellspacing="0" border="0" width="100%">
                    <tbody>
                    <tr>
                        <td width="48" valign="top" align="center">
                            {% set member=entity.member %}

                            <a href="{{ path('user_show', { 'username': member.username }) }}">
                                {% if entity.member.avatar %}
                                    <img src="{{vich_uploader_asset(member,'userImage')|imagine_filter('small_image')}}"/>
                                {% else %}
                                    <img src="{{ asset('bundles/blackhouseappbluehouseapp/images/user_default.png') }}"/>
                                {% endif %}
                            </a>


                        </td>
                        <td width="10"></td>

                        <td width="auto" valign="middle"><span class="box-item-title"><a
                                        href="{{ path('post_show', { 'id': entity.id }) }}">{{ entity.title }}</a></span>

                            <div class="h_5"></div>
                    <span class="box-small box-fade"><div class="box-votes"></div>
                        <a class="box-node" href="{{ path('post_by_node', { 'currentNodeId': entity.node.id }) }}">{{ entity.node.name }}</a> &nbsp;•&nbsp;
                        <strong><a href="{{ path('user_show', { 'username': entity.member.username }) }}">
                                {% if entity.member.nickname %}
                                    {{ entity.member.nickname }}
                                {% else %}
                                    {{ entity.member.username }}
                                {% endif %}
                            </a></strong> &nbsp;•&nbsp; {{ entity.modified|date("Y-m-d H:m") }}
                        {% if lastComments[entity.id] %}
                            {% set member= lastComments[entity.id].member %}
                            &nbsp;•&nbsp; 最后回复来自 <strong>
                            <a
                                    href="{{ path('user_show', { 'username': member.username }) }}">
                                {% if member.nickname %}
                                    {{ member.nickname }}
                                {% else %}
                                    {{ member.username }}
                                {% endif %}
                            </a>
                        </strong>
                        {% endif %}
                    </span>
                        </td>
                        <td width="50" align="right" valign="middle">
                            {%  if entity.commentCount>0 %}
                                <a href="#" class="box-count-livid">{{ entity.commentCount }}</a>
                            {% endif %}
                        </td>
                    </tr>
                    </tbody>

                </table>
            </div>
        {% endfor %}


    </div>
    {{ knp_pagination_render(entities) }}


    <!-- 节点内容 -->
    <div class="h20"></div>
    <div class="box">
        <div class="box-cell">
            <div class="box-fr"><a href="#">浏览全部节点</a></div>
            <span class="box-fade"><strong>蓝房子</strong> / 节点导航</span>
        </div>

        {% for category in categories %}
            {% if loop.last %}
                <div class="box-inner">
            {% else %}
                <div class="box-cell">
            {% endif %}
                    <table cellpadding="0" cellspacing="0" border="0">
                        <tbody>
                            <tr>
                                <td align="right" width="60">
                                    <span class="box-fade">{{ category.name }}</span>
                                </td>
                                <td style="line-height: 200%; padding-left: 10px;">

                                    {% if category.nodes %}
                                        {% set nodes=category.nodes %}
                                        {% for node in nodes %}
                                            {% if node.status %}
                                                {% if node.enabled %}
                                                    <a href="{{ path('post_by_node', { 'currentNodeId': node.id }) }}" style="font-size: 14px;"> {{ node.name }}</a>&nbsp; &nbsp;
                                                {% endif %}
                                            {% endif %}


                                        {% endfor %}
                                    {% endif %}


                                </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
        {% endfor%}
    </div>


{% endblock %}